# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: rubicon <rubicon@mailo.com>
pkgname=epic5
pkgver=3.0.1
pkgrel=0
pkgdesc="Enhanced Programmable ircII Client, version 5"
url="https://epicsol.org/"
arch="all"
license="BSD-3-Clause"
makedepends="libarchive-dev ncurses-dev openssl-dev perl-dev"
subpackages="$pkgname-doc $pkgname-script::noarch $pkgname-lite"
source="https://ftp.epicsol.org/pub/epic/EPIC5-PRODUCTION/epic5-$pkgver.tar.gz
	default-to-oftc.patch
	"
# dir for lite variant without libarchive and perl support
_litedir="$srcdir/$pkgname-$pkgver/lite"

build() {
	mkdir -p "$_litedir"
	cp -r configure Makefile.in include source "$_litedir"/

	./configure \
		--build="$CBUILD" \
		--target="$CTARGET" \
		--prefix=/usr \
		--with-ipv6
	make

	cd "$_litedir"
	./configure \
		--build="$CBUILD" \
		--target="$CTARGET" \
		--prefix=/usr \
		--with-ipv6 \
		--without-libarchive \
		--without-perl
	make
}

check() {
	"$builddir"/source/epic5 -v
	"$_litedir"/source/epic5 -v
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm644 -t "$pkgdir"/usr/share/doc/epic5 \
		"$builddir"/doc/*

	rm "$pkgdir"/usr/share/doc/epic5/epic*.1
}

script() {
	pkgdesc="$pkgdesc (bundled scripts)"
	depends="cmd:$pkgname=$pkgver-r$pkgrel"

	amove usr/share/epic5
}

lite() {
	pkgdesc="$pkgdesc (dependency-lite variant)"

	cd "$_litedir"
	make DESTDIR="$subpkgdir" installbin
	rm -vrf "${subpkgdir:?}"/usr/share
}

sha512sums="
52ae82502ea968e36e5b3f9ebd25c2ce0c684b4b16e1505fc71e49976e8e587d463ae03f531b706893060f677196fb6530c8105e00c330cff73a22b7521a85b0  epic5-3.0.1.tar.gz
02f0f1e77c9bb0acf6da53abadd9b74eb732f25c95545b2a2d20c8a96098313cf138962fa33c36c40949bc3fa5825c2035e41a4ee675a2e681ae687ab3be5d07  default-to-oftc.patch
"
